<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var isUgly = function(num) {
    if( num <= 0 ){
        return false
    }
    while( num % 5 == 0 ){
        num = num/5
    }
    while( num % 3 == 0 ){
        num = num/3
    }
    while( num % 2 == 0 ){
        num = num/2
    }
    if( num == 1 ){
        return true
    }else{
        return false
    }
};

var num = 8
console.log(isUgly(num))
    </script>
</body>
</html>